FIND_PACKAGE (Ruby)

IF (USE_VENDORDIRS AND RUBY_VENDORARCH_DIR)
    SET (RUBY_INSTALL_DIR ${RUBY_VENDORARCH_DIR})
ELSE (USE_VENDORDIRS AND RUBY_VENDORARCH_DIR)
    SET (RUBY_INSTALL_DIR ${RUBY_SITEARCH_DIR})
ENDIF (USE_VENDORDIRS AND RUBY_VENDORARCH_DIR)

MESSAGE (STATUS "Ruby executable: ${RUBY_EXECUTABLE}")
MESSAGE (STATUS "Ruby installation dir: ${RUBY_INSTALL_DIR}")

ADD_CUSTOM_COMMAND (
    OUTPUT solv_ruby.c
    COMMAND ${SWIG_EXECUTABLE} -ruby ${SWIG_FLAGS} -I${CMAKE_SOURCE_DIR}/src -o solv_ruby.c ${CMAKE_SOURCE_DIR}/bindings/solv.i
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    DEPENDS ${CMAKE_SOURCE_DIR}/bindings/solv.i
)

ADD_DEFINITIONS(-Wno-unused)
INCLUDE_DIRECTORIES (${RUBY_INCLUDE_PATH})

ADD_LIBRARY (bindings_ruby MODULE solv_ruby.c)
SET_TARGET_PROPERTIES (bindings_ruby PROPERTIES PREFIX "" OUTPUT_NAME "solv")
TARGET_LINK_LIBRARIES (bindings_ruby libsolvext libsolv ${SYSTEM_LIBRARIES})

INSTALL (TARGETS bindings_ruby LIBRARY DESTINATION ${RUBY_INSTALL_DIR})
